package com.ruoyi.consulte.campus.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.consulte.campus.domain.Campus;
import com.ruoyi.consulte.campus.mapper.CampusMapper;
import com.ruoyi.consulte.campus.service.ICampusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 校园动态Service业务层处理
 * 
 * @author duanxinli
 * @date 2025-09-02
 */
@Service
public class CampusServiceImpl implements ICampusService
{
    @Autowired
    private CampusMapper campusMapper;

    /**
     * 查询校园动态
     * 
     * @param id 校园动态主键
     * @return 校园动态
     */
    @Override
    public Campus selectCampusById(String id)
    {

        return campusMapper.selectCampusById(id);
    }

    /**
     * 查询校园动态列表
     * 
     * @param campus 校园动态
     * @return 校园动态
     */
    @Override
    public List<Campus> selectCampusList(Campus campus)
    {
        return campusMapper.selectCampusList(campus);
    }

    /**
     * 新增校园动态
     * 
     * @param campus 校园动态
     * @return 结果
     */
    @Override
    public int insertCampus(Campus campus)
    {
        campus.setId(IdUtils.fastUUID());
        if (campus.getCreateDate()==null){
            campus.setCreateDate(DateUtils.getNowDate());
        }
        String username = SecurityUtils.getUsername();
        campus.setCreateBy(username);
        campus.setSort(0L);
        return campusMapper.insertCampus(campus);
    }

    /**
     * 修改校园动态
     * 
     * @param campus 校园动态
     * @return 结果
     */
    @Override
    public int updateCampus(Campus campus)
    {
        return campusMapper.updateCampus(campus);
    }

    /**
     * 批量删除校园动态
     * 
     * @param ids 需要删除的校园动态主键
     * @return 结果
     */
    @Override
    public int deleteCampusByIds(String[] ids)
    {
        return campusMapper.deleteCampusByIds(ids);
    }

    /**
     * 删除校园动态信息
     * 
     * @param id 校园动态主键
     * @return 结果
     */
    @Override
    public int deleteCampusById(String id)
    {
        return campusMapper.deleteCampusById(id);
    }
}
